﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace YinyuSearch
{
    public partial class toolsDialog : Form
    {
        public string DbPath = "";

        public delegate void ChooseTools(int i);

        public ChooseTools ct;

        public toolsDialog()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ct(int.Parse(((ListItem) comboBox1.SelectedItem).ID));
            this.Close();
        }

        private void toolsDialog_Load(object sender, EventArgs e)
        {
            string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DbPath + ";Persist Security Info=False";
            OleDbConnection Conn = new OleDbConnection(ConnStr);
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = Conn;
            cmd.CommandText = "Select * from yy_tools";
            Conn.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                ListItem li = new ListItem(dr["id"].ToString(), dr["tools"].ToString());
                comboBox1.Items.Add(li);
            }
        }
    }
}
